﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.SharePoint.Commands;
using SPVSX.Explorer.Extensions;
using Microsoft.SharePoint;
using SPVSX.Explorer.Extensions.NodeInformation;
using SPVSX.Explorer.Extensions.CommandIds;

namespace SPVSX.Explorer.Commands
{
    class CustomActionGroupCommands
    {
        // Gets data for each Custom Action Group on the SharePoint site, and returns an array of 
        // serializable objects that contain the data.
        [SharePointCommand(CustomActionGroupCommandIds.GetCustomActionGroups)]
        private static CustomActionGroupNodeInfo[] GetCustomActionGroups(ISharePointCommandContext context)
        {
            var nodeInfos = new List<CustomActionGroupNodeInfo>();

            //Here is where this will call out to the smarts from SAS but for now create some dummy data

            for (int i = 0; i < 10; i++)
            {
                CustomActionGroupNodeInfo info = new CustomActionGroupNodeInfo();
                info.Name = "Name " + i.ToString();

                nodeInfos.Add(info);
            }

            return nodeInfos.ToArray();
        }

        // Gets additional property data for a specific Custom Action Group.
        [SharePointCommand(CustomActionGroupCommandIds.GetCustomActionGroupProperties)]
        private static Dictionary<string, string> GetCustomActionGroupProperties(ISharePointCommandContext context,
            CustomActionGroupNodeInfo nodeInfo)
        {
            //As the get of the info object is already expensive here we simply read back the properties from it
            //rather than harvest it again

            return SharePointCommandServices.GetProperties(nodeInfo);
        }
    }
}